﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.Refer;
using PowerCreator.LMS.Refer.Entity;

public partial class sysadmin_ReferManager_AddReversion : PowerCreator.LMS.Web.Base.BasePage
{
    Refer objRefer = new Refer();
    public int ReferID = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (IsLicensed(PowerCreator.LMS.Action.Core.ActionInfo.AddJob))
        //{
        //    Script.RedirectURL(GetRefUrl());
        //}
        if (!IsPostBack)
        {
            InitPage();
            if (Request.QueryString["ReferID"] != null)
            {
                ReferID = int.Parse(Request.QueryString["ReferID"].ToString());
                if (ReferID != 0)
                {
                    ViewState["ReferID"] = ReferID.ToString();
                    BinderRefer(ReferID);
                }
            }
        }
    }
    protected override void InitPage()
    {
        //lbl_InfoTitle.Text = GetLanageValueByKey("lbl_AddJob_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_JobName.Text = GetLanageValueByKey("lbl_AddJob_JobName", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_JobDescription.Text = GetLanageValueByKey("lbl_AddJob_JobDescription", PowerCreator.LMS.Language.LanagetItemType.Page);

        //btnSave.Text = GetLanageValueByKey("btn_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        //btnReset.Text = GetLanageValueByKey("btn_Reset", PowerCreator.LMS.Language.LanagetItemType.Page);
        //base.InitPage();

        lbl_InfoTitle_AddReversion.Text = GetLanageValueByKey("msg_refer_msg1", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_ReferInfo.Text = GetLanageValueByKey("msg_refer_msg2", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_ReferNameTitle.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";
        //lab_ReferName.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";
        lab_ReferTimeTitle.Text = "<img src=\"../../images/Refer/time.gif\" width=\"16\" height=\"15\" alt=\"time\" />";
        //lab_ReferTime.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";
        lab_ReferEmailTitle.Text = "<img src=\"../../images/Refer/mailto.gif\" width=\"16\" height=\"16\" alt=\"Email\" />";
        //lab_ReferEmail.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";
        lab_ReferTelephoneTitle.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";
        //lab_ReferTelephone.Text = "<img src=\"../../images/Refer/qq.gif\" width=\"16\" height=\"16\" alt=\"QQ\" id=\"IMG1\" language=\"javascript\" />";



        lbl_ReferTitleTitle.Text = "<img src=\"../../images/Refer/foot.gif\" width=\"15\" height=\"15\" alt=\"Tille\" />"+ GetLanageValueByKey("msg_refer_msg3", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_ReferContentTitle.Text = "<img src=\"../../images/Refer/edit.gif\" width=\"16\" height=\"16\" alt=\"edit\" />" + GetLanageValueByKey("msg_refer_msg4", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_ReferAnswer.Text = GetLanageValueByKey("msg_refer_msg5", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_ReferState.Text = GetLanageValueByKey("msg_refer_msg6", PowerCreator.LMS.Language.LanagetItemType.Page);


        //lbl_ReferPictureUrl.Text = "图片";
        //lbl_ReferPictureUrl_intro.Text = "只有在前台页面做特殊展示，例如做图片新闻时才需上传！";

        btnSave.Text = GetLanageValueByKey("btn_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        btnReset.Text = GetLanageValueByKey("btn_Reset", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }
    private void BinderRefer(int id)
    {
        VOTRefer vo = new VOTRefer();
        vo = objRefer.Load(id);
        lab_ReferName.Text = vo.ReferName;
        lab_ReferTime.Text = vo.ReferTime.ToString();
        lab_ReferEmail.Text = vo.ReferEmail;
        lab_ReferTelephone.Text = vo.ReferTelephone;
        lbl_ReferTitle.Text = vo.ReferTitle;
        lbl_ReferContent.Text = vo.ReferContent;
        txt_ReferAnswer.Text = vo.ReferAnswer;
        if (vo.ReferState == true)
            cb_ReferState.Checked = true;

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        VOTRefer vo = new VOTRefer();
        if (ViewState["ReferID"] != null)
        {
            vo = objRefer.Load(int.Parse(ViewState["ReferID"].ToString()));
        }
        vo.ReferAnswer = txt_ReferAnswer.Text;
        if (cb_ReferState.Checked == true)
            vo.ReferState = true;
        vo.ReferRestoreTime = DateTime.Now;
        if (objRefer.Update(vo))
        {
            string url = "ManagerRefer.aspx";
            Script.RedirectURL(url);
        }
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        string url = "ManagerRefer.aspx";
        Script.RedirectURL(url);
    }
}
